<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
       select{
           width: 100px;
       }

    </style>
</head>
<body>

      <span>请选你购买的数量</span>
      <select name="" id="num">
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
      </select>
    
</body>
</html>

<script>

  let selectObj = document.getElementById('num');

  //console.log(selectObj.value);

  selectObj.onchange=()=>{
      let val= selectObj.value;
      console.log(val);
  }

</script>